/**
 * MarioEnemy_Patroller
 * @extends GamePawn
 * @version 2010.12.04
 */

class MarioEnemy_Patroller extends GamePawn
	placeable;

var MarioAI_Patrol  MyController;
var float           Speed;
var bool            bplayed;
var Vector          spawnPoint;
var StaticMeshComponent shell;
var(NPC) StaticMeshComponent NPCMesh;
var bool            isShell;
var bool AttAcking;

var() array<NavigationPoint> MyNavigationPoints;

function addComponents() { }

/**
 * SetCharacterClassFromInfo - why is this just empty?
 * @version 2010.12.04
 */
simulated function SetCharacterClassFromInfo(class<UTFamilyInfo> Info) { }


/**
 * Bump
 * @version 2010.12.04
 */
event Bump(Actor Other, PrimitiveComponent OtherComp, vector HitNormal)
{
	 local GamePawn HitPawn;
	 HitPawn = GamePawn(Other);

	 if(round(HitNormal.Z) == 1.00) 
	 {
	 	`log("Hit on top!");

		//Why LinkPlasma? Just for testing?
		TakeDamage(50, HitPawn.Controller, HitPawn.Location, vect(1, 1, 1), class'UTDmgType_LinkPlasma');

		//Destroy();
		if(HitPawn.isPlayerPawn()) 
		{
			`log("I make player jump!");
			HitPawn.DoJump(FALSE);
		}
		
		if(Health <= 50 && Health > 10)
		{
			`log("ME IS A SHELL");
			addComponents();
			Velocity.X = 0;
			Velocity.Y = 0;
			Acceleration = vect(0,0,0);
		}
	}
	else if(HitPawn.isPlayerPawn() && round(HitNormal.Z) != 1.00 && HitPawn.Location.Z - Location.Z <= GetCollisionHeight()) 
	{
		`log("I KEEL YOU");
		if(HitPawn.Health > 100 && HitPawn.Health <= 150)
			HitPawn.ThrowActiveWeapon(true);
		else if(HitPawn.Health >50 && HitPawn.Health <=100)
			MarioPawn(HitPawn).ShrinkHeight();
		//HitPawn.SetActiveWeapon(None);
		`log("health: "$MarioPawn(Other).Health);
		HitPawn.TakeDamage(50, Controller, Location, vect(1, 1, 1), class'UTDmgType_LinkPlasma');
		`log("health: "$MarioPawn(Other).Health);
		//HitPawn.Suicide();	
	} 
}

state Dead
{
	Begin:
	Destroy();
}

defaultproperties
{
	Begin Object Class=DynamicLightEnvironmentComponent Name=MyLightEnvironment
		ModShadowFadeoutTime        = 0.25;
		MinTimeBetweenFullUpdates   = 0.20;

		AmbientGlow         = (R = .01, G = .01, B = .01, A = 1.0);
		AmbientShadowColor  = (R = .15, G = .15, B = .15);
		LightShadowMode     = LightShadow_ModulateBetter;
		ShadowFilterQuality = SFQ_High;
		bSynthesizeSHLight  = TRUE;
	End Object

	Components.Add(MyLightEnvironment);

	Components.Remove(Sprite);
	Components.Remove(Sprite);

	NPCMesh = StaticMeshComponent0;
	Mesh    = SkeletalMeshComponent0;
	Components.Add(StaticMeshComponent0);

	CollisionType = COLLIDE_BlockAll;

	Begin Object Name=CollisionCylinder
		CollisionRadius = +0010.000000;
		CollisionHeight = +0040.000000;
	End Object

	CylinderComponent = CollisionCylinder;

	bCollideActors      = TRUE
	bPushesRigidBodies  = TRUE
	bMovable            = TRUE
	bCollideWorld       = TRUE;
	bStatic             = FALSE

	bAvoidLedges        = TRUE
	bStopAtLedges       = TRUE

	bBlockActors        = TRUE;

	Health              = 50;
	JumpZ               = 700;
	Speed               = 80;

	LedgeCheckThreshold = 0.5;
	bDirectHitWall = true;
}

simulated event HitWall(Object.Vector HitNormal, Actor Wall, PrimitiveComponent WallComp)
{
	super.HitWall(HitNormal, Wall, WallComp);
}

function SetAttacking(bool atacar)
{
	AttAcking = atacar;
}